import {request} from '@umijs/max';
import * as API from "@/services";


/** 素材 分页检索请求 */
export async function queryMaterials(params: API.MaterialPageQueryParams): Promise<API.RespPageResult<API.Material>> {
  return request('/api/v1/material', {
    params,
  });
}

/** 素材 详情请求 */
export async function queryMaterial(bizId: API.EntityId): Promise<API.RespResult<API.Material>> {
  return request(`/api/v1/material/${bizId}`);
}

/** 素材 创建请求 */
export async function createMaterial(entity: API.Material_Create): Promise<API.RespResult<any>> {
  return request(`/api/v1/material`, {
    method: 'POST',
    data: entity,
  });
}

/** 创建(多文件) **/
export async function createMaterials(entity: API.Material_BatchUrlsCreate): Promise<API.RespResult<any>> {
  return request(`/api/v1/material/batch-urls`, {
    method: 'POST',
    data: entity,
  });
}


/** 素材 修改请求 */
export async function modifyMaterial(entity: API.Material_Modify): Promise<API.RespResult<any>> {
  return request(`/api/v1/material/${entity.id}`, {
    method: 'PUT',
    data: entity,
  });
}

/** 素材 修改(部分)请求 */
export async function patchMaterial(entity: API.Material_Patch): Promise<API.RespResult<any>> {
  return request(`/api/v1/material/${entity.id}`, {
    method: 'PATCH',
    data: entity,
  });
}

/** 素材 删除请求 */
export async function deleteMaterial(bizId: API.EntityId): Promise<API.RespResult<any>> {
  return request(`/api/v1/material/${bizId}`, {
    method: 'DELETE',
  });
}

/** 素材 批量删除请求 */
export async function deleteMaterials(bizIds: API.EntityId[]): Promise<API.RespResult<any>> {
  return request(`/api/v1/material`, {
    method: 'DELETE',
    data: {
      ids: bizIds,
    },
  });
}


/** 素材 移动(批量)请求 */
export async function moveMaterials(data: API.Material_MoveBatch): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/material/move`, {
    method: 'PUT',
    data: data,
  });
}


